package com.study.homework;

public class LinkedStack {

    Node header;

    public LinkedStack() {

    }

    public void push(int a) {
        Node node = getNode(a);
        node.next = header;
        header = node;
    }

    private Node getNode(int a) {

        return new Node(a);
    }

    public int pop() {
        Node node = header;
        header = header.next;
        node.next = null;
        return node.data;
    }

    public void clear() {
        header = null;
    }

    public int peek() {
        return header.data;
    }
}
